package org.example.booklist.mapper;

import com.sun.source.tree.LambdaExpressionTree;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.example.booklist.model.BookInfo;
import org.example.booklist.model.PageResult;
import org.springframework.stereotype.Service;

import java.util.List;

@Mapper
public interface  BookMapper {

    //book_name, author, count, price, publish, `status`
    //插入图书的操作：，返回一个Integer，影响的行数
    @Insert("insert into book_info (book_name, author, count, price, publish, `status`)"+
    "values (#{bookName}, #{author}, #{count}, #{price}, #{publish}, #{status})")
    Integer insertBook(BookInfo bookInfo);

    //queryBookByPage
    @Select("select * from book_info  where status != 0 order by id desc limit #{offset}, #{limit}")
    List<BookInfo> queryBookPage(Integer offset, Integer limit);


    @Select("select count(1) from book_info where status != 0")
    Integer count();


    @Select("select * from book_info where id = #{bookId}")
    BookInfo queryBookById(Integer bookId);

    Integer updateBookById(BookInfo bookInfo);


    Integer batchDeleteBookByIds(List<Integer> ids);



}
